package cn.changeforyou.web.cloud.webBase.platform;

import cn.changeforyou.base.exception.ExceptionFactory;
import cn.changeforyou.base.exception.SystemExceptionEnum;

import javax.servlet.http.HttpServletRequest;

/**
 * 平台工具
 */
public class PlatformUtils {

    public static PlatformEnum getPlatform(HttpServletRequest request) {
        String platform = request.getHeader("platform");
        if(null != platform) {
            PlatformEnum platformEnum = PlatformEnum.valueOf(platform);
            if(null == platformEnum) {
                throw ExceptionFactory.jsonException(SystemExceptionEnum.NO_PLATFORM_INFO);
            }
            return platformEnum;
        }else{
            //后面需要分才扩展, 比如,java, web, 工具包含postman等
            return PlatformEnum.java;
        }
    }
}
